package com.jueecy.service.Impl;

import com.jueecy.mapper.GoodsMapper;
import com.jueecy.pojo.Goods;
import com.jueecy.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {


    @Autowired
    private GoodsMapper goodsMapper;

    //添加商品
    @Override
    public Integer addGoods(Goods goods) {
        return goodsMapper.addGoods(goods);
    }

    @Override
    public List<Goods> queryAllGoods() {

        List goodsList=goodsMapper.queryAllGoods();
        return goodsList;

    }

    @Override
    public List<Goods> queryShoppingCart(Integer user_id) {
        List goodsList=goodsMapper.queryShoppingCart(user_id);
        return goodsList;
    }

    @Override
    public Integer addToShoppingCart(Integer user_id, Integer goods_id) {
        return goodsMapper.addToShoppingCart(user_id,goods_id);
    }

    @Override
    public Integer deleteFromShoppingCart(Integer user_id, Integer goods_id) {
        return goodsMapper.deleteFromShoppingCart(user_id,goods_id);
    }

    @Override
    public List<Goods> findGoodsByType(Integer goods_type) {
        List goodsList=goodsMapper.findGoodsByType(goods_type);
        return goodsList;
    }

    @Override
    public List<Goods> searchGoodsByName(String keywords) {
        List goodsList=goodsMapper.searchGoodsByName(keywords);
        return goodsList;
    }

    @Override
    public List<Goods> alreadySell(Integer user_id) {
        List goodsList=goodsMapper.alreadySell(user_id);
        return goodsList;
    }

    @Override
    public Integer deleteMyGoods(Integer user_id, Integer goods_id) {
        return goodsMapper.deleteMyGoods(user_id,goods_id);
    }


}
